package com.sali.config;

import java.io.Serializable;


/**
 * 返回消息对象
 */
public class ReturnModel<T> implements Serializable {
    private int code;

    private String message;

    public static <T> ReturnModel getInstance() {
        return new ReturnModel();
    }

    public ReturnModel ok() {
        this.setCode(ReturnCode.SUCCESS.getCode());
        this.setMsg(ReturnCode.SUCCESS.getMessage());
        return this;
    }

    public ReturnModel error() {
        this.setCode(ReturnCode.ERROR.getCode());
        this.setMsg(ReturnCode.ERROR.getMessage());
        return this;
    }

    public ReturnModel setCode(int code) {
        this.code = code;
        return this;
    }


    public ReturnModel setMsg(String msg) {
        this.message = msg;
        return this;
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
